
package vv.lines.core;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author vpotapenko
 */
public class BallBuffer implements Iterable<Ball> {

    private List<Ball> balls;

    public BallBuffer() {
        balls = new ArrayList<Ball>();
    }

    public void add(Ball ball) {
        if (ball != null) balls.add(ball);
    }

    public void add(Collection<Ball> balls) {
        for (Ball ball : balls) {
            add(ball);
        }
    }

    public void remove(Ball ball) {
        if (ball != null) balls.remove(ball);
    }

    public Ball remove(int idx) {
        return balls.remove(idx);
    }

    public void clear() {
        balls.clear();
    }

    public int size() {
        return balls.size();
    }

    public List<Ball> asList() {
        return balls;
    }

    public boolean isEmpty() {
        return balls.isEmpty();
    }

    public Iterator<Ball> iterator() {
        return balls.iterator();
    }
}
